//
//  CertReasonFlags.m
//  TestProject
//
//  Created by 武侠 on 2022/2/18.
//  Copyright © 2022 zhulong. All rights reserved.
//

#import "CertReasonFlags.h"

@implementation CertReasonFlags

- (void)loadCertData {
    [super loadCertData];
    
    self.unused               = [self bit:7];
    self.keyCompromise        = [self bit:6];
    self.cACompromise         = [self bit:5];
    self.affiliationChanged   = [self bit:4];
    self.superseded           = [self bit:3];
    self.cessationOfOperation = [self bit:2];
    self.certificateHold      = [self bit:1];
    self.privilegeWithdrawn   = [self bit:0];
    self.aACompromise         = [self bit:15];
}

- (NSString *)description {
    NSMutableArray *array = [NSMutableArray array];
    if (self.unused == YES) {
        [array addObject:@"unused()"];
    }
    if (self.keyCompromise == YES) {
        [array addObject:@"keyCompromise()"];
    }
    if (self.cACompromise == YES) {
        [array addObject:@"cACompromise()"];
    }
    if (self.affiliationChanged == YES) {
        [array addObject:@"affiliationChanged()"];
    }
    if (self.superseded == YES) {
        [array addObject:@"superseded()"];
    }
    if (self.cessationOfOperation == YES) {
        [array addObject:@"cessationOfOperation()"];
    }
    if (self.certificateHold == YES) {
        [array addObject:@"certificateHold()"];
    }
    if (self.privilegeWithdrawn == YES) {
        [array addObject:@"privilegeWithdrawn()"];
    }
    if (self.aACompromise == YES) {
        [array addObject:@"aACompromise()"];
    }
    if (array.count > 0) {
        NSMutableString *str = [NSMutableString stringWithString:@"\n\t\t\t["];
        [str appendString:[array componentsJoinedByString:@", "]];
        [str appendString:@"]"];
        return str;
    }
    return [super description];
}

@end
